<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width: 530px;
            margin: 0 auto;
            display: flex;
            overflow: hidden;
            justify-content: space-between;
            flex-wrap: wrap;
        }

        img{
            opacity: 0.3;
        }
        /* img:hover{
            opacity: 1;
        } */
    </style>
</head>
<body>
    <div class="box">
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
        <div><img src="./1.jpg" alt=""></div>
    </div>
    <script>
        var img = document.getElementsByTagName('img')
        for(var i=0; i<img.length; i++){
            img[i].onmouseenter = function(){
                this.style.opacity = 1
                
            }
            img[i].onmouseleave = function(){
                this.style.opacity = 0.3
                
            }
        }
    </script>
</body>
</html>